<!--  -->
<template>
  <div>

    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">权限管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card class="box-card">
      <el-table :data="rightsList"
                style="width: 100%"
                stripe
                :border="true">
        <el-table-column type="index">
        </el-table-column>
        <el-table-column prop="authName"
                         label="权限名称"
                         width="180">
        </el-table-column>
        <el-table-column prop="path"
                         label="商品管理"
                         width="180">
        </el-table-column>
        <el-table-column prop="level"
                         label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level==0">标签一</el-tag>
            <el-tag type="success"
                    v-else-if="scope.row.level==1">标签二</el-tag>
            <el-tag type="info"
                    v-else>标签三</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { reqGetRights } from '@/api/index'
export default {
  data () {
    return {
      // 权限列表数据
      rightsList: []
    }
  },
  methods: {
    async getRights () {
      const { data: res } = await reqGetRights('list')
      if (res.meta.status != 200) {
        return this.$message.error('获取权限列表失败')
      }
      this.rightsList = res.data
    }
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created () {

  },
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted () {
    this.getRights()
  }
}
</script>
<style lang="less" scoped>
.el-breadcrumb {
  margin: 0 0 20px;
  font-size: 12px;
}
.el-card {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.15) !important;
}
</style>
